home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 2.iso / toolbox / public / figlet / figlet2.1.1 / figlist < prev    next >
Text File  |  1996-11-11  |  2KB  |  93 lines

  1. #!/bin/sh -
  2. # figlist by Glenn Chappell <ggc@uiuc.edu>
  3. # File counting by Bruce Jakeway <pbjakewa@barrow.uwaterloo.ca>
  4. # 28 Apr 1995
  5. #
  6. # Lists all fonts and control files in figlet's default font directory.
  7. # Replaces "figlet -F", which was removed from figlet version 2.1.
  8. #
  9. # Usage: figlist [ -d directory ]
  10. #
  11. # If this script doesn't work on your system, try
  12. # figlet -F        (figlet 2.0)
  13. # ls `figlet -I2`  (figlet 2.1 or later)
  14. #
  15. # Or, if the problem is only that your system doesn't have the "wc" (word
  16. # count) program, put a "#" at the beginning of the two lines containing
  17. # "wc", i.e., the lines beginning "NUMFONTS=" and "NUMCONTROL=".
  18.  
  19. # Set up PATH so figlet can be found
  20. DIRSAVE=`pwd`
  21. cd `(dirname "$0") 2>/dev/null`
  22. PATH="$PATH":`pwd`
  23. cd "$DIRSAVE"
  24.  
  25. # Get figlet version
  26. FIGVERSION=`figlet -I1 2>/dev/null`
  27. if [ -z "$FIGVERSION" ]; then
  28.   FIGVERSION=20000
  29. fi
  30.  
  31. USAGE="Usage: `basename $0` [ -d directory ]"
  32.  
  33. if [ "$1" = "-d" ]; then
  34.   FONTDIROPT="-d $2"
  35.   if [ $# -ne 2 ]; then
  36.     echo "$USAGE" >&2
  37.     exit 1
  38.   fi
  39. else
  40.   FONTDIROPT=""
  41.   if [ $# -ne 0 ]; then
  42.     echo "$USAGE" >&2
  43.     exit 1
  44.   fi
  45. fi
  46.  
  47. if [ "$FIGVERSION" -lt 20100 ]; then
  48.   # figlet 2.0
  49.   figlet -F | sed -e '2,$d'
  50.   FONTDIR="`figlet -F | sed -e '1d' -e '3,$d' -e 's/.*: //'`"
  51. else
  52.   # figlet 2.1 or later
  53.   echo "Default font: `figlet -I3`"
  54.   FONTDIR=`figlet $FONTDIROPT -I2`
  55. fi
  56. echo "Font directory: $FONTDIR"
  57.  
  58. if [ ! -d "$FONTDIR" ] || [ ! -r "$FONTDIR" ]; then
  59.   echo 'Unable to open directory'
  60.   exit
  61. fi
  62. cd "$FONTDIR"
  63.  
  64. NUMFONTS=`ls *.flf 2>/dev/null | wc -l | sed 's/^ *//'`
  65. echo ""
  66. if [ "$NUMFONTS" = 0 ]; then
  67.   echo 'No figlet fonts in this directory'
  68. else
  69.   if [ "$NUMFONTS" -eq 1 ]; then
  70.     echo "1 figlet font in this directory:"
  71.   else
  72.     echo $NUMFONTS "figlet fonts in this directory:"
  73.   fi
  74.   ls -C *.flf 2>/dev/null | expand | sed s/\.flf\\\>//g
  75. fi
  76.  
  77. if [ $FIGVERSION -lt 20100 ]; then
  78.   exit
  79. fi
  80.  
  81. NUMCONTROL=`ls *.flc 2>/dev/null | wc -l | sed 's/^ *//'`
  82. echo ""
  83. if [ "$NUMCONTROL" = 0 ]; then
  84.   echo 'No figlet control files in this directory'
  85. else
  86.   if [ "$NUMCONTROL" -eq 1 ]; then
  87.     echo "1 figlet control file in this directory:"
  88.   else
  89.     echo $NUMCONTROL "figlet control files in this directory:"
  90.   fi
  91.   ls -C *.flc 2>/dev/null | expand | sed s/\.flc\\\>//g
  92. fi
  93.